﻿<div class="jumbotron">
    <h1>ASP.NET</h1>
    <p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS, and JavaScript.</p>
    <p><a href="http://asp.net" class="btn btn-primary btn-lg">Learn more &raquo;</a></p>
</div>
<div class="row">
    <div class="col-md-4">
        <h2>Getting started</h2>
        <p>
            ASP.NET Web API is a framework that makes it easy to build HTTP services that reach
            a broad range of clients, including browsers and mobile devices. ASP.NET Web API
            is an ideal platform for building RESTful applications on the .NET Framework.
        </p>
        <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301870">Learn more &raquo;</a></p>
    </div>
    <div class="col-md-4">
        <h2>Get more libraries</h2>
        <p>NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.</p>
        <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301871">Learn more &raquo;</a></p>
    </div>
    <div class="col-md-4">
        <h2>Web Hosting</h2>
        <p>You can easily find a web hosting company that offers the right mix of features and price for your applications.</p>
        <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301872">Learn more &raquo;</a></p>
    </div>
    <form action="/Api/userinfo" onsubmit="return false;" method="post">
        <label>用户名：<input type="text" name="username" value="" /></label><br />
        <label>密码：<input type="text" name="password" value="" /></label><br />
        <label>接口地址：<input type="text" name="url" value="" /></label><br />
        <label>请求方式：<select name="type">
            <option value="get">GET</option>
            <option value="post">POST</option>
            </select></label><br />
        <label>接口地址：<input type="text" name="param" value="" /></label><br />
        <button type="button" onclick="GoSubmit();">提交</button>
        <br />
        <button type="button" onclick="GetTest();">测试</button>
    </form>
</div>
<script type="text/javascript" src="http://localhost:98/Resources/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
    var sk = '', host = "http://localhost:29656";
    function GoSubmit() {
        $.post(host + "/api/userinfo/login", { username: $('input[name="username"]').val(), password: $('input[name="password"]').val(), dt: new Date().getTime() }, function (rtn) {
            if (rtn.state == 200) {
                sk = rtn.data.sk;
            }
            alert(rtn.state);

        }, 'json');
    }
    function GetTest() {
        alert(sk);
        //$.ajax({
        //    type: "GET",
        //    url: host + '/api/userinfo/students',
        //    dataType: "json",
        //    data: {id:55},
        //    beforeSend: function (xhr) { xhr.setRequestHeader('SessionKey', sk); },
        //    sucess: function (rtn) {
        //        console.log(rtn);
        //    }
        //});
        var param = JSON.parse($('input[name="param"]').val())
        $[$('select[name="type"]').val()](host + $('input[name="url"]').val(), $.extend(param, { sk: sk }), function (rtn) {
            console.log(rtn);
        }, 'json');
    }
</script>